cmake_minimum_required(VERSION 3.0)
 
project(test_mqtt)

set(CMAKE_BUILD_TYPE Debug)
# set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "-std=c++14 -O0 -pthread  -fpermissive")

# set(CMAKE_BUILD_TYPE Release)
# set(CMAKE_CXX_FLAGS "-std=c++14 -O0 -pthread  -fpermissive")


set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)


#===========================component 组件======================#
set(COMT ${CMAKE_CURRENT_SOURCE_DIR}/src/components)
#drivers驱动层
include_directories (${COMT}/drivers)
aux_source_directory(${COMT}/drivers SRC_DIR)
#lib
include_directories (${COMT}/lib)
aux_source_directory(${COMT}/lib SRC_DIR)

include_directories (${COMT}/lib/database) # database
include_directories (${COMT}/lib/database/easysqlite)
aux_source_directory(${COMT}/lib/database SRC_DIR)
include_directories (${COMT}/lib/lib_cserialport) # serialport
include_directories (${COMT}/lib/lib_json) # jsoncpp
include_directories (${COMT}/lib/lib_json/json)
include_directories (${COMT}/lib/lib_json/serialize)
aux_source_directory(${COMT}/lib/lib_json SRC_DIR)
aux_source_directory(${COMT}/lib/lib_json/serialize SRC_DIR)
include_directories (${COMT}/lib/libhv/hv) # libhv
include_directories (${COMT}/lib/libpaho) # mqtt paho c++
include_directories (${COMT}/lib/libzlog) # zlog
aux_source_directory(${COMT}/lib/libzlog SRC_DIR)
#protocol协议层
include_directories (${COMT}/protocol)

#controller 通道-协议-处理
include_directories(${COMT}/controller)
include_directories(${COMT}/controller/base)
include_directories(${COMT}/controller/link)
include_directories(${COMT}/controller/packet)
include_directories(${COMT}/controller/process)

aux_source_directory(${COMT}/controller SRC_DIR)
aux_source_directory(${COMT}/controller/base SRC_DIR)
aux_source_directory(${COMT}/controller/link SRC_DIR)
aux_source_directory(${COMT}/controller/packet SRC_DIR)
aux_source_directory(${COMT}/controller/process SRC_DIR)

#===========================app  应用===========================#
set(APP ${CMAKE_CURRENT_SOURCE_DIR}/src/app)
aux_source_directory(${APP} SRC_DIR)
include_directories (${APP})
#数据
include_directories (${APP}/data)
include_directories (${APP}/data/config)
include_directories (${APP}/data/real_time_data)
aux_source_directory(${APP}/data/config SRC_DIR)
aux_source_directory(${APP}/data/real_time_data SRC_DIR)
#设备
include_directories (${APP}/device)
include_directories (${APP}/device/modbus)
aux_source_directory(${APP}/device/modbus SRC_DIR)
aux_source_directory(${APP}/device SRC_DIR)
#服务
include_directories (${APP}/server)
include_directories (${APP}/server/https)
include_directories (${APP}/server/mqtt)
include_directories (${APP}/server/SL651)
aux_source_directory(${APP}/server SRC_DIR)
aux_source_directory(${APP}/server/https SRC_DIR)
aux_source_directory(${APP}/server/mqtt SRC_DIR)
aux_source_directory(${APP}/server/SL651 SRC_DIR)


#====main=============//
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC_DIR)


set(ENABLE_TEST TRUE)


#====test cpp=========
if(ENABLE_TEST)
    message(WARNING "》》》》》》》》》》》》》》》》》》》》》使用测试《《《《《《《《《《《《《《《《《")


    set( SRC_TEST
        # test/components/lib/json/test_json_serialize.cpp
        # test/components/lib/json/test_json.cpp
        # test/components/lib/database/test_database.cpp
        # test/app/data/test_RealTimeData.cpp
        # test/test_foreach.cpp
        # test/components/lib/mqtt/test_mqtt_publish_rt.cpp
        # test/components/lib/libhv/test_http.cpp
        # test/components/lib/libhv/test_tcp.cpp

        test/components/lib/libhv/test_http_server.cpp

        # test/components/lib/log/test_zlog.cpp
        # test/components/lib/serialport/test_serialport.cpp
        # test/components/controller/test_controller.cpp
        test/components/controller/test_LinkTcpClient.cpp
        test/components/controller/test_LinkSerialPort.cpp
        test/components/controller/test_LinkMqttClient.cpp
        test/components/controller/test_IMode.cpp
        test/components/controller/test_packet_modbus.cpp
        test/components/controller/test_packet_sl651.cpp
        test/components/controller/test_process_modbus.cpp

         
        test/main.cpp
    )
    add_executable(${PROJECT_NAME} ${SRC_DIR} ${SRC_TEST} )

else()
    add_executable(${PROJECT_NAME} ${SRC_DIR})

endif()


link_libraries(/usr/local/lib)

TARGET_LINK_LIBRARIES(${PROJECT_NAME} 
-ldl -leasysqlite
-lpaho-mqtt3cs
-lhv
-lzlog
-lcserialport
)

